package org.example.controller;

import org.example.model.common.dtos.ResponseResult;
import org.example.model.minio.MinioPojo;
import org.example.service.MinioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * minio文件管理
 */
@CrossOrigin
@RestController
@RequestMapping("/file")
public class MinioController {

    @Autowired
    private MinioService minioService;

    @Autowired
    private MinioPojo minioPojo;

    /**
     * 文件上传
     */
    @PostMapping("/minio-upload-file")
    public ResponseResult UploadImage(@RequestParam("file") MultipartFile file) {
        return ResponseResult.okResult(minioService.UploadFile(minioPojo.getBucketName(),file));
    }
}
